package com.situ.springboot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.springboot.mapper.AuthMapper;
import com.situ.springboot.pojo.Auth;
import com.situ.springboot.pojo.query.AuthQuery;
import com.situ.springboot.service.IAuthService;
import com.situ.springboot.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthServiceImpl implements IAuthService {

    @Autowired
    private AuthMapper authMapper;

    @Override
    public PageResult<Auth> selectByPage(AuthQuery authQuery) {
        PageHelper.startPage(authQuery.getPage(), authQuery.getLimit());
        List<Auth> list = authMapper.selectByPage(authQuery);
        PageInfo<Auth> pageInfo = new PageInfo<>(list);
        int totalCount = pageInfo.getPages();
        return new PageResult<>(0, "", totalCount, list);
    }
}
